geometry *2100

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
#define iset indexed_set
#define int long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define ff first
#define ss second
#define mk make_pair
#define pb push_back
#define rep(i, start, end) for (int i = start; i < end; i++)
#define ld long double
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int inf = 1000000000000000000;
using ii = pair<int, int>;
const static int mx = 2e5 + 100;
int sx, sy, tx, ty;
int v, t;
int vx, vy, wx, wy;
bool check(ld val)
{
    ld xx = sx, yy = sy;
    if (val > t)
    {
        xx += t * vx;
        yy += t * vy;
        ld temp = val - t;
        xx += temp * wx;
        yy += temp * wy;
    }
    else
    {
        xx += val * vx;
        yy += val * vy;
    }
    ld dist = (xx - tx) * (xx - tx) + (yy - ty) * (yy - ty);
    dist = sqrtl(dist);
    if (dist <= (ld)(val * v))
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
void solve()
{
    cin >> sx >> sy >> tx >> ty;
    cin >> v >> t;
    cin >> vx >> vy >> wx >> wy;
    ld hi = 1e9, lo = 0, ans = -1, mid;
    while ((hi - lo) > 1e-8)
    {
        mid = (hi + lo) / 2.0;
        if (check(mid))
        {
            ans = mid;
            hi = mid - 1e-8;
        }
        else
        {
            lo = mid + 1e-8;
        }
    }
    cout << fixed << setprecision(8) << ans << "\n";
}
// don't get stuck on a idea
// always write brute force if you cannot think of anything....remember you are anyways not going to
// do anything during the contest
// if constraints are small try to think about dp
// take a deep breathe and think. No hurry.
signed main()
{
    fast
    solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

84. Largest Rectangle in Histogram
60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship